package com.nxbw.controller;


import com.nxbw.pojo.dto.AcceptanceQuery;
import com.nxbw.pojo.dto.AcceptanceSaveParam;
import com.nxbw.response.JsonResult;
import com.nxbw.service.AcceptanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/acceptance")
public class AcceptanceController {

    @Autowired
    AcceptanceService acceptanceService;

    @GetMapping("select")
    public JsonResult getAcceptanceList(AcceptanceQuery acceptanceQuery) {
        log.debug("查询入参:{}", acceptanceQuery);
        List<AcceptanceQuery> list = acceptanceService.getValitionQueryList(acceptanceQuery);
        log.debug("查询结果出参:{}", list);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveAcceptance(@RequestBody AcceptanceSaveParam acceptanceSaveParam) {
        log.debug("保存入参:{}", acceptanceSaveParam);
        acceptanceService.saveAcceptance(acceptanceSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("update")
    public JsonResult updateAcceptance(@RequestBody AcceptanceSaveParam acceptanceSaveParam) {
        log.debug("更新入参:{}", acceptanceSaveParam);
        acceptanceService.saveAcceptance(acceptanceSaveParam);
        return JsonResult.ok();
    }


    @PostMapping("delete/{id}")
    public JsonResult deleteAcceptance(@PathVariable Integer id) {
        log.debug("删除入参:{}", id);
        acceptanceService.deleteAcceptance(id);
        return JsonResult.ok();
    }





}
